package com.acme.bankapp.domain.bank.account;

/**
 * This is abstract class which implements {@link Account} interface
 *
 * @author Alexander Kotov
 */

public abstract class AbstractAccount implements Account {

    protected double balance;

    public AbstractAccount(double balance) throws IllegalArgumentException{
        super();
        if (balance < 0) {
            throw new IllegalArgumentException("Negative balance");
        }
        this.balance = balance;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public double getBalance() {
        return balance;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void deposit(double amount) {
        balance += amount;
    }
}
